exports.convertToChinaTime=(utcTimeStr) =>{
    // 将UTC时间字符串转换为Date对象
    const utcDate = new Date(utcTimeStr);

    // 获取中国时区偏移，东八区为 +08:00
    const chinaTimeOffset = 8 * 60; // 分钟

    // 将UTC时间转换为中国时间
    const chinaDate = new Date(utcDate.getTime() + chinaTimeOffset * 60 * 1000);

    // 格式化中国时间为字符串
    const year = chinaDate.getFullYear();
    const month = String(chinaDate.getMonth() + 1).padStart(2, '0');
    const day = String(chinaDate.getDate()).padStart(2, '0');
    const hours = String(chinaDate.getHours()).padStart(2, '0');
    const minutes = String(chinaDate.getMinutes()).padStart(2, '0');
    const seconds = String(chinaDate.getSeconds()).padStart(2, '0');

    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}


exports.getCurrentTime=()=> {
    // 创建一个新的 Date 对象
    const now = new Date();

    // 获取不同部分的时间
    const year = now.getFullYear();
    const month = now.getMonth() + 1; // 月份从0开始，所以需要加1
    const day = now.getDate();
    const hours = now.getHours();
    const minutes = now.getMinutes();
    const seconds = now.getSeconds();

    // 格式化时间为字符串
    const currentTime = year + '-' + 
                      (month < 10 ? '0' : '') + month + '-' + 
                      (day < 10 ? '0' : '') + day + ' ' + 
                      (hours < 10 ? '0' : '') + hours + ':' + 
                      (minutes < 10 ? '0' : '') + minutes + ':' + 
                      (seconds < 10 ? '0' : '') + seconds;

    return currentTime;
}


